package com.lb.jwitter.action;


import java.util.Collection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import java.util.Map; 
import org.springframework.test.context.ContextConfiguration; 
import com.lb.jwitter.service.TblQuyenChiTietService; 
import com.lb.jwitter.service.TblTaiKhoan; 
import com.opensymphony.xwork2.ActionContext; 
import com.lb.jwitter.util.ApplicationContextProvider; 
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.opensymphony.xwork2.Action; 
import com.lb.jwitter.service.TblThongTinHocVienDTB;
import com.lb.jwitter.service.TblThongTinHocVienDTBService;
import com.lb.jwitter.service.TblThongTinHocVien;
import com.lb.jwitter.service.TblThongTinHocVienService;

 /** 
 * @author QUOCVIET  
 * 
 */ 


@ContextConfiguration(locations="classpath:beans.xml") 
public class TblThongTinHocVientblThongTinHocVienDTBEditFormAction{
    private int id; 
    public void setId(int id) {
       this.id = id;
 }

    public int getId() {
       return id;
 }

    private TblThongTinHocVienDTB tblThongTinHocVienDTB; 
    public TblThongTinHocVienDTB getTblThongTinHocVienDTB() { 
        return tblThongTinHocVienDTB; 
    } 
    private TblThongTinHocVien tblThongTinHocVien; 
    public TblThongTinHocVien getTblThongTinHocVien() { 
        return tblThongTinHocVien; 
    } 
    private Collection<TblThongTinHocVienDTB> tblThongTinHocVienDTBs; 
    public Collection<TblThongTinHocVienDTB>  getTblThongTinHocVienDTBs() {
         return tblThongTinHocVienDTBs; 
      } 

    private TblThongTinHocVienDTBService tblThongTinHocVienDTBService; 

    private Collection<TblThongTinHocVien> tblThongTinHocViens; 
    public Collection<TblThongTinHocVien>  getTblThongTinHocViens(){ 
              return tblThongTinHocViens; 
     } 

    private TblThongTinHocVienService tblThongTinHocVienService; 

  private TblTaiKhoan taiKhoanDangNhap; 
 public TblTaiKhoan getTaiKhoanDangNhap() { 
     return taiKhoanDangNhap; 
 } 
 public void setTaiKhoanDangNhap(TblTaiKhoan taiKhoanDangNhap) { 
     this.taiKhoanDangNhap = taiKhoanDangNhap; 
 } 
 private TblQuyenChiTietService tblQuyenChiTietService;
	 @Autowired // Injected by Spring 
     ApplicationContextProvider contextProvider; 
    public String execute() throws Exception 
   { 
    try{ 
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_ThongTin_HocVien_DTB", "sua")){ 
        return "noprivilege"; 
    }        tblThongTinHocVienDTBService = (TblThongTinHocVienDTBService) context.getBean("tbl_ThongTin_HocVien_DTBClient"); 
        tblThongTinHocVienService = (TblThongTinHocVienService) context.getBean("tbl_ThongTin_HocVienClient"); 

        tblThongTinHocVienDTB = tblThongTinHocVienDTBService.gettblThongTinHocVienDTB(new Long(id)); 
        tblThongTinHocVien = tblThongTinHocVienDTB.getHocVienId(); 
        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
      System.out.println("Loi EditForm tbl_ThongTin_HocVien_DTB Action"); 
     e.printStackTrace(); 
    return Action.ERROR; 
 } 
 } 
 } 
 
